package com.haiheng.library_base.db

import androidx.room.*

/**
 *
 * @Des:
 * @Author: hwz
 * @Date:2022/5/25 0025
 * @Version: 1.0
 */
@Dao
interface BookInventoryInfoDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insert(bookInventoryInfo: BookInventoryInfo): Long

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insert(bookInventoryInfo: List<BookInventoryInfo>): List<Long>

    @Delete
    suspend fun delete(bookInventoryInfo: BookInventoryInfo): Int

    @Delete
    fun deleteList(bookInventoryInfo: List<BookInventoryInfo>)

    // 删除表中所有数据
    @Query("DELETE FROM book_inventory_info")
    suspend fun deleteAll()

    @Update
    suspend fun update(layerMap: BookInventoryInfo): Int

    @Query("SELECT * FROM book_inventory_info WHERE barCode IN(:barCode)")
    suspend fun queryByBarCode(barCode: String): BookInventoryInfo

    @Query("SELECT * FROM book_inventory_info")
    suspend fun queryInfo():  List<BookInventoryInfo>

    @Query("SELECT * FROM book_inventory_info WHERE invertoryInfoStatus IN(:invertoryInfoStatus)")
    fun queryByInvertoryInfoStatus(invertoryInfoStatus:Int): List<BookInventoryInfo>

    @Query("SELECT * FROM book_inventory_info WHERE misShelvedStatus IN(:misShelvedStatus)")
    fun queryByMisShelvedStatus(misShelvedStatus:Int): List<BookInventoryInfo>

}